{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<title>编辑字段</title>
<link rel="stylesheet" href="{% static '/public/css/ui.css' %}">
<link rel="stylesheet" href="{% static '/public/admin/css/layout.css' %}">
<script src="{% static 'public/js/jquery.js' %}"></script>
<script src="{% static 'public/js/ui.js' %}"></script>
</head>

<body>
    <div class="position">当前位置：系统管理 > <a href="{% url 'manager:configgroup_index' %}">设置分组</a> > <a href="{% url 'manager:configgroupfield_index' gid %}">字段管理</a> > <a href="{% url 'manager:configgroupfield_edit' id %}">编辑字段</a></div>
    <div class="borders">
        <!---->
        
        <div class="ui-tabs ui-tabs-white" data-href="1">
            <ul class="ui-tabs-nav">
              <li class="active"><a href="{% url 'manager:configgroupfield_edit' id %}">编辑字段</a></li>
            </ul>
            <div class="ui-tabs-content">
                <div class="ui-tabs-pane active">
                    <!--loop-->
                    <form class="ui-form" method="post">
                        <div class="ui-form-group ui-row">
                            <label class="col-left ui-col-form-label">字段名称：</label>
                            <div class="col-right">
                                <input type="text" name="ctitle" class="ui-form-ip" placeholder="请输入字段名称" data-rule="字段名称:required;" value="{{ctitle}}">
                            </div>
                        </div>
                        <div class="ui-form-group ui-row">
                            <label class="col-left ui-col-form-label">字段Key：</label>
                            <div class="col-right">
                                <input type="text" name="ckey" class="ui-form-ip" disabled placeholder="字母和数字的组合，长度3-50个字符" data-rule="字段Key:required;" value="{{ckey}}">
                            </div>
                        </div>
                        <div class="ui-form-group ui-row">
                            <label class="col-left ui-col-form-label">字段类型：</label>
                            <div class="col-right">
                                <select name="ctype" id="ctype" class="ui-form-ip" data-rule="字段名称:required;">
                                    <option value="0">请选择字段类型</option>
                                    <option value="1"{% if ctype == 1 %} selected{% endif %}>普通文本</option>
                                    <option value="2"{% if ctype == 2 %} selected{% endif %}>普通文本-密码</option>
                                    <option value="4"{% if ctype == 4 %} selected{% endif %}>普通文本-上传</option>
                                    <option value="5"{% if ctype == 5 %} selected{% endif %}>多行文本框</option>
                                    <option value="6"{% if ctype == 6 %} selected{% endif %}>单选按钮</option>
                                    <option value="7"{% if ctype == 7 %} selected{% endif %}>复选框</option>
                                    <option value="8"{% if ctype == 8 %} selected{% endif %}>下拉列表</option>
                                    <option value="9"{% if ctype == 9 %} selected{% endif %}>间隔标题</option>
                                </select>
                            </div>
                        </div>
                        <div class="ui-form-group ui-row dis" id="list">
                            <label class="col-left ui-col-form-label">候选值：</label>
                            <div class="col-right">
                                <textarea name="dvalue" rows="5" class="ui-form-ip">{{dvalue}}</textarea>
                                <span class="input-tips">示范：项目名称1|项目值1<br>　　　项目名称2|项目值2</span>
                            </div>
                        </div>
                        <div class="ui-form-group ui-row dis" id="upload_type">
                            <label class="col-left ui-col-form-label">上传类型：</label>
                            <div class="col-right">
                                <select name="utype" class="ui-form-ip" data-rule="上传类型:required;">
                                    <option value="0"{% if utype == 0 %} selected{% endif %}>请选择上传类型</option>
                                    <option value="1"{% if utype == 1 %} selected{% endif %}>只能上传图片</option>
                                    <option value="2"{% if utype == 2 %} selected{% endif %}>只能上传视频</option>
                                    <option value="3"{% if utype == 3 %} selected{% endif %}>全部都可以上传</option>
                                </select>
                            </div>
                        </div>
                        <div class="ui-form-group ui-row">
                            <label class="col-left ui-col-form-label">提示文字：</label>
                            <div class="col-right">
                                <input type="text" name="dtext" class="ui-form-ip" value="{{dtext}}">
                            </div>
                        </div>
                        <div class="ui-form-group ui-row">
                            <label class="col-left ui-col-form-label">字段排序：</label>
                            <div class="col-right">
                                <input type="text" name="ordnum" class="ui-form-ip" value="{{ordnum}}">
                                <span class="input-tips">数字越小越靠前</span>
                            </div>
                        </div>
                        <div class="ui-form-group ui-row dis" id="showway">
                            <label class="col-left">排列方式：</label>
                            <div class="col-right">
                                <label class="ui-radio"><input type="radio" name="rtype" id="rtype_1" value="1"{% if rtype == 1 %} checked{% endif %}><i></i>横排</label>
                                <label class="ui-radio"><input type="radio" name="rtype" id="rtype_2" value="2"{% if rtype == 2 %} checked{% endif %}><i></i>竖排</label>
                            </div>
                        </div>
                        <div class="ui-form-group ui-row">
                            <label class="col-left ui-col-form-label">状态：</label>
                            <div class="col-right col-right-top">
                                <label class="ui-radio"><input type="radio" name="islock" id="islock_1" value="1"{% if islock == 1 %} checked{% endif %}><i></i>正常</label>
                                <label class="ui-radio"><input type="radio" name="islock" id="islock_2" value="0"{% if islock == 0 %} checked{% endif %}><i></i>锁定</label>
                            </div>
                        </div>
                        <div class="ui-form-group ui-row">
                                <label class="col-left ui-col-form-label"></label>
                                <div class="col-right">
                                	{% csrf_token %}
                                    <button type="submit" class="ui-btn ui-btn-info ui-mr">保存</button>
                                    <button type="button" class="ui-btn ui-back">返回</button>
                                </div>
                            </div>
                    </form>
                    <!--loop-->
                </div>
            </div>
        </div>
        
        <!---->
    </div>


<script>
$(function()
{

    $("#ctype").change(function()
	{
        switch ($(this).val())
        {
			case "4":
				$("#upload_type").removeClass("dis");
				$("#list,#showway").addClass("dis");
				break;
			case "7":
			case "8":
			 	$("#list").removeClass("dis");
				$("#showway,#upload_type").addClass("dis");
                break;
            case "6":
                $("#list,#showway").removeClass("dis");
				$("#upload_type").addClass("dis");
                break;
            default:
                $("#list,#showway,#upload_type").addClass("dis");
                break;
        }
    });
	{% if ctype == 4 %}
	$("#upload_type").removeClass("dis");
	$("#list,#showway").addClass("dis");
	{% elif ctype == 7 or ctype == 8 %}
	$("#list").removeClass("dis");
	$("#showway,#upload_type").addClass("dis");
	{% elif ctype == 6 %}
	$("#list,#showway").removeClass("dis");
	$("#upload_type").addClass("dis");
	{% else %}
	$("#list,#showway,#upload_type").addClass("dis");
	{% endif %}
    
    $(".ui-form").form(
	{
		type:2,
		result:function(form)
		{
			$.ajax(
			{
                type:'post',
                cache:false,
                dataType:'json',
                url:'{% url "manager:configgroupfield_edit" id %}',
                data:$(form).serialize(),
                error:function(e){alert(e.responseText);},
                success:function(d)
                {
                    if(d.state=='success')
                    {
                        wmcms.success(d.msg);
                        setTimeout(function(){location.href='{% url "manager:configgroupfield_index" gid%}';},1500);
                    }
                    else
                    {
                        wmcms.error(d.msg);
                    }
                }
            });
		}
	});
})
</script>
</body>
</html>